import { http } from "@/lib";
import { message, Modal } from "antd";

const confirm = Modal.confirm

export const resetPassword = (option) => {
  const { params, url } = option
  return http.post(url,params).then(res=>{
    message.success('密码重置成功')
  })
}

export const enableHandle = (option) => {
  const { flag, params, url, cb } = option
  const type = flag?"启用":"禁用"
  confirm({
    title: '确定要'+type+'所选账号吗？',
    onOk: () => {
      return enableRequest(flag, params, url, cb)
    }
  })
}

export const enableRequest = (flag, params, url, cb) => {
  return http.get(url,{params}).then(res=>{
    const msg = flag?"启用成功":"禁用成功"
    message.success(msg)
    cb&&cb(res)
  })
}